import {Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, VersionColumn} from "typeorm"
import {SysMenuTypeEnum} from "../consts/entity/SysMenuEnums";


@Entity({
    name: "sys_menu"
})
export class SysMenu {

    constructor() {
        this.id = 0
        this.title = ''
        this.code = ''
        this.parentId = 0
        this.icon = ''
        this.url = ''
        this.type = SysMenuTypeEnum.MENU.valueOf()
        this.sort = 1
        this.createTime = ''
        this.updateTime = ''
        this.version = 1
    }

    @PrimaryGeneratedColumn({
        type: "bigint"
    })
    id: number

    @Column({
        type: "varchar"
    })
    title: string

    @Column({
        type: "varchar"
    })
    code: string

    @Column({
        type: "bigint",
        default: 0,
        name: "parent_id"
    })
    parentId: number

    @Column({
        type: "varchar"
    })
    icon: string

    @Column({
        type: "varchar"
    })
    url: string

    @Column({
        type: "varchar",
        enum: SysMenuTypeEnum
    })
    type: number

    @Column({
        type: "int",
        default: 1
    })
    sort: number

    @CreateDateColumn({
        type: "datetime",
        name: "create_time"
    })
    createTime: string

    @UpdateDateColumn({
        type: "datetime",
        name: "create_time"
    })
    updateTime: string

    @VersionColumn({
        type: "int"
    })
    version: number
}


